<?php

    function cnv($text)
    {
        return $text; // i conv("UTF-8", "WINDOWS-1251", $text);
    }

    function cnv_to($text)
    {
        return $text; // i conv("WINDOWS-1251", "UTF-8", $text);
    }

    function CallSoap($function, $parameters)
    {    
        global $mikron;
        $soap = new SoapClient(constant('SOAP_HOST'));
        $params = Array();
        $params['MethodName'] = $function;
        $params['XML'] = $parameters;
        $resp = $soap->Operation($params);
        
        $resp->XML = str_replace('UTF-16', 'utf-8', $resp->XML);
        $resp->XML = str_replace('utf-16', 'utf-8', $resp->XML);

        if($resp->MethodName == 'error')
        {
            $mikron->Cache->setCache('error', $resp->XML);
            $mikron->Tools->GoToPage('/infomat/error.php');
        }

        if($resp->MethodName == 'authentification')
        {
            session_destroy();
            header('Location: /infomat/index.php');
            exit;
        }

        return $resp->XML;

    }
?>